#pragma once
#include <string>
#include "UIComponent.h"
#include <pspkernel.h>
#include <curl/curl.h>

static double progress;

class Peer{
   public:
        double totaltime;
        double totalbyte;

        Peer(std::string,std::string);
        int tuid;
        void run();

        void runsingle();
        void runprogress();

        static int ThreadEntry(SceSize args, void *argp){
           Peer *sef = *(Peer **) argp;
           sef->runprogress();
           return 0;
        }

        static void CreateTask(Peer* peer){
            peer->tuid = sceKernelCreateThread(peer->_name,Peer::ThreadEntry, 0x10, 0x10240, PSP_THREAD_ATTR_USER, 0);
            if(peer->tuid >= 0){
              sceKernelStartThread(peer->tuid, sizeof(peer), &peer);
            }
        }
   private:
        char* _name; //full name of resource
        char* _url;  //download url
};
